﻿using System;
using System.IO; //Stream
using System.Diagnostics;
using System.Threading;

namespace negoserverjni
{
    public class InsideStream:Stream
    {
        internal static TraceSource log = new TraceSource("InsideStream");

        Spnego spnego;
        public InsideStream(Spnego nego)
        {
            spnego = nego;
        }
        public override void Write(byte[] buffer, int offset, int length){throw new NotImplementedException();}
        public override int Read(byte[] buffer, int offset, int length){throw new NotImplementedException();}
        public override void SetLength(long length){throw new NotImplementedException();}
        public override long Seek(long position, SeekOrigin origin){throw new NotImplementedException();}
        public override void Flush() { }
        public override long Position { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } }
        public override long Length { get { throw new NotImplementedException(); } }
        public override bool CanWrite { get { return true; } }
        public override bool CanSeek { get { return false; } }
        public override bool CanRead { get { return true; } }
        public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, Object state)
        {
            log.TraceEvent(TraceEventType.Verbose,Thread.CurrentThread.ManagedThreadId,"BeginRead");
            return spnego.SendToNegoStream(buffer, offset, count, callback, state);
        }
        public override int EndRead(IAsyncResult asyncResult)
        {
            return spnego.EndSendToNegoStream(asyncResult);
        }

        public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
        {
            log.TraceEvent(TraceEventType.Verbose,Thread.CurrentThread.ManagedThreadId,"BeginWrite");
            return spnego.ReceiveFromNegoStream(buffer, offset, count, callback, state);
        }
        public override void EndWrite(IAsyncResult asyncResult)
        {
            log.TraceEvent(TraceEventType.Verbose,Thread.CurrentThread.ManagedThreadId,"EndWrite");
            return;
        }
        protected override void Dispose(bool disposing)
        {
            return;
        }
        
    }


}
